#!/bin/sh
#   The above line causes this script to be run using the Bourne Shell (sh)
#######################################################################
#
#   Script to maintain a contacts database.
#
#######################################################################

#
#   Define the name of the file
#
fname=names.dat

#
#   Read in the contact details from the keyboard
#
echo "Please enter the following contact details:"
echo
echo "Given name: \c"
read name
echo "   Surname: \c"
read surname
echo "   Address: \c"
read address
echo "      City: \c"
read city
echo "     State: \c"
read state
echo "       Zip: \c"
read zip

#
#   Write the details to the text file
#
echo $name:$surname:$address:$city:$state:$zip >> $fname

#
#   Show what's currently in the file
#
(
    echo
    echo Here are the current contacts in the database:
    echo
    cat $fname
) | more

#
#  And display how many there are
#
echo
echo There are `cat $fname | wc -l` contacts in the database
